import 'dart:io';

import 'package:environmental_les_app/common/utils/sp_util.dart';
import 'package:flutter_clx_base/flutter_clx_base.dart';
import '../utils/device_utils.dart';

class HeaderInterceptor extends InterceptorsWrapper {
  @override
  onRequest(RequestOptions options, handler) async {
    var deviceModel = await DeviceUtils.getDeviceModel();
    var deviceSerial = await DeviceUtils.getDeviceSerial();
    var versionName = await DeviceUtils.getVersionName();
    var versionCode = await DeviceUtils.getVersionCode();
    options.headers['authorization'] = getToken();
    options.headers['client-type'] = Platform.isIOS ? "ios" : "android";
    options.headers['device-id'] = deviceSerial;
    options.headers['versionCode'] = versionCode;
    options.headers['versionName'] = versionName;
    options.headers['model'] = deviceModel;
    options.headers['imei'] = deviceSerial;
    // 人脸识别使用
    options.headers["productChannel"] = Platform.isIOS
        ? "ios_app"
        : Platform.isAndroid
            ? "android_app"
            : "";

    return super.onRequest(options, handler);
  }
}
